package com.auto.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

//@Service
public class Red implements ApplicationContextAware {
	private ApplicationContext applicationContext;
	
	@Value("${person.nickName}")
	String name;

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		// 通过ApplicationContextAware接口的实现类，获取到spring上下文的ApplicationContext
		this.applicationContext = applicationContext;
		Yellow yellow = this.applicationContext.getBean(Yellow.class);
		System.out.println("通过底层接口获取到IOC中的Bean：>" + yellow);
	}
	

	public Red() {
		super();
		System.out.println("--->");
		System.out.println(name);
	}
	
	
}
